<%@page import="content.GroupContent"%>
<%@page import="transfer.User"%>
<%@page import="entity.GroupsLocal"%>
<%@page import="transfer.Group"%>
<%@page import="java.util.ArrayList"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="entity.GroupsLocalHome"%>
<div class="block-header">Groups</div>
<div class="box">
    <table class="table" rules=all>
        <tr>
            <td width="30px;"><input type="checkbox" id='all_groups'></td>
            <td>Name</td>
            <td>Users</td>
        </tr>
        <%
            ArrayList grouplist = GroupContent.getAllGroups();
            for (int i = 0; i < grouplist.size(); i++) {
                Group group = (Group) grouplist.get(i);
                int groupId = group.getIdGroup().intValue();
        %>
        <tr>
            <td><input type="checkbox" id='<%= groupId %>' name='groups'></td>
            <td><a href="admin.jsp?content=group&operation=view&id=<%=groupId%>"><%=group.getNameGroup()%></a></td>
            <td>
                <%
                    for (int j = 0; j < group.getUsers().size(); j++) {
                        User user = (User) group.getUsers().get(j);
                        out.print(user.getLogin());
                        if (j < group.getUsers().size() - 1) {
                            out.print(", ");
                        }
                    }
                %>
            </td>
        </tr>
        <%
            }
        %>
    </table>
</div>